<!--ajax查表实例-->
<!--本文件需要jq.js和ajaxeq.php支持-->
<html>
	<head>
		<meta charset="UTF-8">
		<title>ajaxeq</title>
		<script src="jq/jquery-3.3.1.min.js" type="text/javascript"></script>
	</head>
	<body>
		<input type="button" onclick="manage()" value="manage表"/>
		<input type="button" onclick="newstypes()" value="newstypes表"/>
		<input type="button" onclick="test()" value="empty"/><br /><br />
		自定义SQL语句：<input type="text" name="" id="diy" value="select * from newstypes where typeId < 3" style="width: 600px;"/>
		<input type="button" onclick="diy()" value="提交sql" />
		<div id="diva"></div>
	</body>
	<script type="text/javascript">
		window.onload=function(){//初始加载
			$("#diva").append("<br><br><span>点击按钮使用ajax调用ajaxeq.php查询对应表里的数据</span>");
		}
		function manage(){
			$.ajax({
				type:"post",
				url:"ajaxeq.php",
				dateType:"html",
				data:"sql=select * from manager",
				success:function(data){
					$('#diva').empty();
					$("#diva").append("<p>此次执行的sql语句是：select * from manager</p>");
					$('#diva').append("<div>"+data+"</div>");
				}
			});
		}
		function newstypes(){
			$.ajax({
				type:'post',
				url:"ajaxeq.php",
				dataType:"html",
				data:"sql=select * from newstypes",
				success:function(data){
					$("#diva").empty();
					$("#diva").append("<p>此次执行的sql语句是：sql=select * from newstypes</p>");
					$("#diva").append("<div>"+data+"</div>");
				}
			})
		}
		function test(){
			$('#diva').empty();
		}
		function diy(){
			var sql=$("#diy").val();
			$.ajax({
				type:"post",
				url:"ajaxeq.php",
				dataType:"html",
				data:"sql="+sql,
				success:function(data){
					$("#diva").empty();
					$("#diva").append("<p>此次执行的sql语句是："+sql+"</p>");
					$("#diva").append("<div>"+data+"</div>");
				}
			});
		}
	</script>
</html>
